using System.Linq;
using System.Web.Mvc;
using MvcMall.AdminPortal.Controllers.AdminModul.ViewModels;
using MvcMall.Core.Contacts.Tasks;
using MvcMall.Framework.Mapper;

namespace MvcMall.AdminPortal.Controllers.AdminModul
{
    public class AdminModulController : BaseController
    {
        private readonly IAdminModulTask _adminModulTask;
        private readonly IMapper<Core.Domains.AdminModul, AdminModulDtoModel> _mapper;

        public AdminModulController(IAdminModulTask adminModulTask, IMapper<Core.Domains.AdminModul, AdminModulDtoModel> mapper)
        {
            _adminModulTask = adminModulTask;
            _mapper = mapper;
        }

        public ActionResult Index()
        {
            var list = _adminModulTask.GetAll().OrderBy(m => m.Id);
            var model = list.Select(_mapper.MapFrom).ToList();
            return View(model);
        }
    }
}